package com.devperson.callable.runnableResult;

import java.util.concurrent.*;

public class RunMyResult {
    public static void main(String[] args) throws Exception {
        String result = "这是传入的值";
        RunnableResult runnableResult = new RunnableResult(result);
        ThreadPoolExecutor executor = new ThreadPoolExecutor(2,3,5L, TimeUnit.SECONDS,new LinkedBlockingQueue<>());

        // String 作为参数进行传递，submit中的result是不能进行有效的返回的。由此可以看出，String作为参数传递的时候，传递的是值
        Future future = executor.submit(runnableResult,result);
        try {
            System.out.println("future的返回值=="+future.get());
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
        ResultObject resultObject = new ResultObject();
        resultObject.setResult("这是传入的测试数据");
        RunMyResultObject myResultObject = new RunMyResultObject(resultObject);
        Future future1 = executor.submit(myResultObject,resultObject);
        System.out.println("future.get=" + future1.get());
        System.out.println(resultObject.toString());



    }
}
